"""
根据传入的名称以及config构建query analyse 处理类
"""
from rank.quality_feature import QualityFeature
from rank.time_feature import TimeFeature
from rank.relative_feature import RelativeFeature
from rank.relevance_feature import RelevanceFeature
from rank.authority_feature import AuthorityFeature


class FeatureFactory:
    @classmethod
    def create_service(cls, config):
        service = None
        if config["name"] == "quality_feature":
            service = QualityFeature(config)
        elif config["name"] == "time_feature":
            service = TimeFeature(config)
        elif config["name"] == "relative_feature":
            service = RelativeFeature(config)
        elif config["name"] == "relevance_feature":
            service = RelevanceFeature(config)
        elif config["name"] == "authority_feature":
            service = AuthorityFeature(config)

        if not service:
            print("init query analyse service %s failed " % config["name"])
        return service

